/******************************************************************************
 directional defs-Vory V Zakone
******************************************************************************/
/******************************************************************************
 directions
******************************************************************************/
var NORTH = 1;
var EAST  = 2;
var SOUTH = 3;
var WEST  = 4;
var DOWN  = 1;
var LEFT  = 2;
var RIGHT = 3;
var UP    = 4;
/******************************************************************************
game states
******************************************************************************/
var CLOSED   = 0;
var OPEN     = 1;
var DEAD     = 0;
var DYING    = 1;
var ALIVE    = 2;
var ATTACKED = 3;
var HIT      = 1;
var FALSE    = 0;
var TRUE     = 1;
var DISABLED = 1;
var ENABLED  = 0;
/******************************************************************************
player game state variables
******************************************************************************/
var xcoords = new Array(0, -1, 0, 1);
var ycoords = new Array(-1, 0, 1, 0);

var pxcoord = new Array(0, -1, 0, 1, 0);
var pycoord = new Array(0, 0, 1, 0, -1);
var pxdir   = new Array(0, 0, 1, 0, -1);
var pydir   = new Array(0, 1, 0, -1, 0);

var xcoord  = new Array(0, 1, 0, 0, -1);
var ycoord  = new Array(0, 0, -1, 1, 0);
var movex   = 0;
var movey   = 0;
/******************************************************************************
 world boundary test
******************************************************************************/
function Bounds(x, y)
 {
  if((x < 0) || (x > MAP_X) || (y < 0) || (y > MAP_Y))
   { return 1; }
  return 0;
 }
/******************************************************************************
 key handler codes
******************************************************************************/
var N_ARROW   = 38;
var S_ARROW   = 40;
var W_ARROW   = 37;
var E_ARROW   = 39;
var SHIFT     = 16;
var TELEPORT  = 70;
var SANCTUARY = 84;
/******************************************************************************
spell identifiers
******************************************************************************/
var CLOUD_OF_CONFUSION = 0;
var BALL_OF_LIGHT      = 1;
var FROST_SPRAY        = 2;
var LIGHTNING_BOLT     = 3;
var FIREBALL           = 4;
var FIREBURST          = 5;
var FLAMING_DEATH      = 6;
/******************************************************************************
 pixel maps for easier positioning and moving of sprites - just snap in the
 x-y coordinates to access correct position.
 Pixels = positioning for 96x96 format (player and monsters)
 MPixels = positioning for 200x150 format (message bubble)
 IPixels = position for 64x64 format (items)
******************************************************************************/
 
var Pixels = new Array("10px", "48px", "112px", "176px", "240px", "304px", "368px", "432px", 
                       "496px", "560px", "624px", "688px", "752px", "816px", "880px", "944px",
                       "1008px", "1072px", "1136px", "1200px", "1264px");

var MXPixels = new Array("10px", "88px", "152px", "216px", "280px", "344px", "408px", "472px", 
                         "534px", "600px", "664px", "728px", "792px", "856px", "920px", "984px",
                         "1048px", "1112px", "1176px", "1240px", "1304px");

var MYPixels = new Array("5px", "60px", "125px", "190px", "250px", "315px", "380px", "440px", 
                         "505px", "570px", "635px", "700px", "765px", "830px", "980px", "955px",
                         "1020px", "1085px", "1150px", "1210px", "1275px");
/*
var IPixels = new Array("0px", "64px", "128px", "192px", "256px", "320px", "384px", "448px", 
                       "512px", "576px", "640px", "694px", "758px", "832px", "896px", "960px",
                        "1024px", "1088px", "1148px", "1212px", "1276px");
*/


var IPixels = new Array("0px", "32px", "64px", "96px", "128px", "160px", "192px", "224px", 
                       "256px", "288px", "320px", "352px", "384px", "416px", "448px", "480px",
                        "512px", "544px", "576px", "608px", "640px");

/******************************************************************************
 mage tower test variables
******************************************************************************/
var PowerSquare = 88;
var PowerX      = 4;
var PowerY      = 8;


function log (message) {
document.getElementById('__debug').value = message;
}